home *** CD-ROM | disk | FTP | other *** search
- /*
- ** This source code was written by Tim Endres
- ** Email: time@ice.com.
- ** USMail: 8840 Main Street, Whitmore Lake, MI 48189
- **
- ** Some portions of this application utilize sources
- ** that are copyrighted by ICE Engineering, Inc., and
- ** ICE Engineering retains all rights to those sources.
- **
- ** Neither ICE Engineering, Inc., nor Tim Endres,
- ** warrants this source code for any reason, and neither
- ** party assumes any responsbility for the use of these
- ** sources, libraries, or applications. The user of these
- ** sources and binaries assumes all responsbilities for
- ** any resulting consequences.
- */
-
- /* Tickle Developers: Mess with this file, and you're dead */
-
- /*
- ** TGEEdit.h -- Tim Endres' Text Edit Manager interface
- **
- ** C Interface to the Macintosh Libraries
- ** Copyright ICE Engineering 1988
- ** All rights reserved.
- */
-
- #ifndef __TGEEDIT__
- #define __TGEEDIT__
-
- #define SANITY 1 /* undefine to remove sanity checks. */
-
- #define T_NEW_STATE 0x00000001
-
- #define T_DEAD_WINDOW_STATE 0x08000000
-
- #define T_TCL_STATE 0x00800000
- #define T_GLOBAL_TCL_STATE 0x00400000
-
- #define T_EXIST_STATE 0x00004000
- #define T_INCOMPLETE_STATE 0x00002000
- #define T_TEMPORARY_STATE 0x00000800
- #define T_TRASHED_STATE 0x00000200
-
- #define T_PREF_SELECT_HEADER_FLAG (0)
-
- #define T_SETSTATE(state,bit) ( (state) |= (bit) )
- #define T_UNSETSTATE(state,bit) ( (state) &= ~(bit) )
- #define T_TESTSTATE(state,bit) ( ( (state) & (bit) ) != 0 )
-
- #define TGE_SCRIPT 0
- #define TGE_SELECTION 1
- #define TGE_ALL 2
-
- #define TGE_FAILURE 0
- #define TGE_SUCCESS 1
- #define TGE_NOT_IN_DISPLAY -98
- #define TGE_MEMORY_ERROR -99
-
- #define ascReturn 13
- #define ascBackSpace 8
-
- #define tgeWKind 2001
-
- #define TGE_PRINTABLE_KEY(key) ( ( (key) >= ' ' && (key) <= '~' ) || \
- ( (key) >= 0x80 && (key) <= 0xD8 ) || \
- ( (key) == '\010' ) || \
- ( (key) == '\011' ) || \
- ( (key) == '\015' ) )
-
-
- #define QD_MAX_COORD 0x7FFF
- #define TGE_MAX_ORIGIN ((QD_MAX_COORD) - 8192)
-
- #define inFront ((WindowPtr) -1)
- #define WPeek ((WindowPeek) myWindow)
-
- #define INIT_NUMBER_BUFFERS 5
- #define BUFFER_PAGE_SIZE (4 * 1024)
-
- #define CARET_BLINK_TICKS 29
- #define CARET_NOT_DISPLAYED 0
- #define CARET_DISPLAYED 1
- #define CARET_NOT_IN_DISPLAY -1
-
- #define BUF_MOD_FLAG 0x0400
- #define BUF_RAM_FLAG 0x0100
-
- #define ISMODIFIED(bufptr) ( ((bufptr)->flags & BUF_MOD_FLAG) != 0 )
- #define NOTMODIFIED(bufptr) ( ((bufptr)->flags & BUF_MOD_FLAG) == 0 )
- #define MODIFY(bufptr) ( (bufptr)->flags |= BUF_MOD_FLAG )
- #define UNMODIFY(bufptr) ( (bufptr)->flags &= ~(BUF_MOD_FLAG) )
-
- #define ISRAMBASED(bufptr) ( ((bufptr)->flags & BUF_RAM_FLAG) != 0 )
- #define ISFILEBASED(bufptr) ( ((bufptr)->flags & BUF_RAM_FLAG) == 0 )
- #define RAMBASED(bufptr) ( (bufptr)->flags |= BUF_RAM_FLAG )
- #define FILEBASED(bufptr) ( (bufptr)->flags &= ~(BUF_RAM_FLAG) )
-
- typedef struct {
- char *fpathname;
- char *ffilename;
- long fdirid;
- short fvrefnum;
- short ffileref;
- } FileDef, *FileDefPtr;
-
- typedef struct TEXTBUFFER {
- short flags;
- long v_begin;
- long v_end;
- long file_begin;
- long file_end;
- Handle text_handle;
- long text_length;
- struct TEXT_BUFFER *fnext;
- } text_buffer, *text_buf_ptr;
-
- #define TGE_UNDO_NOOP 0
- #define TGE_UNDO_PASTE 1
- #define TGE_UNDO_CLEAR 2
- #define TGE_UNDO_CLEAR_PASTE 3
- #define TGE_UNDO_CLEAR_TYPING 4
-
- #define TGE_UNDO_STATE 0
- #define TGE_REDO_STATE 1
-
- #define TGE_UNDO_NOT_TYPING 0
- #define TGE_UNDO_START_TYPING 1
- #define TGE_UNDO_IS_TYPING 2
-
- typedef struct {
- short undo_op;
- short undo_state;
- short typing_state;
- short pad1;
- long undo_begin_clear;
- long undo_end_clear;
- long undo_begin_paste;
- long undo_end_paste;
- long typing_begin;
- long typing_end;
- long typing_begin_q;
- long typing_backspace;
- Handle undo_handle;
- Handle undo_back_handle;
- } tge_undo_rec;
-
- typedef struct TGEWINDOW {
- WindowRecord super;
- long state;
- void *fobject; /* interpretter (Tcl_Interp *) */
- /* WINDOW INFORMATION */
- short active;
- short file_based;
- short changed;
- short display_lines;
- text_buf_ptr buffer_pool;
- ControlHandle hscroll;
- ControlHandle vscroll;
- /* FILE INFORMATION */
- FileDef fdef;
- long file_length;
- long v_length;
- /* TEXT DISPLAY INFORMATION */
- Point forigin;
- short text_font;
- short text_size;
- short text_face;
- short line_height;
- short left_margin;
- short top_margin;
- short right_margin;
- short bottom_margin;
- long position;
- FontInfo finfo;
- long sel_start;
- long sel_end;
- Point sel_start_pt;
- Point sel_end_pt;
- short sel_start_displayed;
- short sel_end_displayed;
- Point sel_point;
- long click_time;
- Point caret_point;
- long caret_time;
- short caret_state;
- short caret_invalid;
- short tab_stops;
- short tab_width;
- short wrap_length;
- long *lines;
- long lines_length;
- long num_lines;
- long first_line;
- tge_undo_rec undo;
- } tgeWindowRec, *tgeWindowPtr;
-
- #define TGEWPtr ((tgeWindowPtr) myWindow)
-
- #define TGE_LAST_POSITION(w) ( (((tgeWindowPtr) w)->v_length > 0) ? \
- ((tgeWindowPtr) w)->v_length - 1 : 0 )
-
- #define TGE_box_width 75
- #define TGE_box_base 2
-
- #define TGE_icon_width 16
- #define TGE_icon_height 16
- #define TGE_icon_left 16
-
- #define TGE_minh (TGE_box_width + TGE_icon_width + 32)
- #define TGE_minv 75
-
-
- #define iBeamCursor 1
- #define WatchCursor 4
-
- #define changeid 0
- #define itemmsg 1
- #define itemname 2
- #define itemnum 3
- #define itemtab 4
-
- #define canitem 1
- #define csaveitem 2
- #define noitem 3
- #define checktitle 4
- #define casitem 5
-
-
- #define FILEDEBUG 5
-
- #if FILEDEBUG > 0
-
- extern FILE *fdebug;
-
- #ifdef DEBUG
- # define DEBUGBEG { fdebug = fopen("TGEDEBUG", "a");
- # define DEBUGEND fclose(fdebug); FlushVol(NULL, (short)0); }
- #endif
-
- #endif
-
- #ifdef DEBUG
- # define TGE_DPRINTF(lvl, action) ( ((lvl) <= _tge_debug_level) ? dprintf action : 0 )
- #else
- # define TGE_DPRINTF(lvl, action)
- #endif
-
- text_buf_ptr tge_new_buffer();
- text_buf_ptr tge_get_buffer();
- char *tge_copy_name();
- extern RgnHandle tge_selection_rgn();
-
- //extern Rect scrnrect;
- extern int _tge_debug_level;
-
- extern Handle tge_text_handle();
- extern Handle tge_selection_handle();
- extern Handle tge_new_text_handle();
-
- #endif __TGEEDIT__
-